import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class ZContainer extends StatelessWidget {
  final double radius;
  final BorderRadius? borderRadius;
  final Color? color;
  final Widget? child;
  final double? height;
  final double? width;
  final EdgeInsets? margin;
  final EdgeInsets? padding;
  final Alignment? alignment;
  final BorderSide? side;
  final bool showShadows;
  final BoxConstraints? constraints;
  final Color? shadowColor;
  final double? blurRadius;
  final double? spreadRadius;
  final Offset? shadowOffset;

  const ZContainer({
    super.key,
    this.radius = 0,
    this.borderRadius,
    this.color,
    this.child,
    this.height,
    this.width,
    this.padding,
    this.margin,
    this.alignment,
    this.side,
    this.showShadows = false,
    this.constraints,
    this.shadowColor,
    this.blurRadius,
    this.shadowOffset,
    this.spreadRadius,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      width: width?.r,
      height: height?.r,
      margin: margin?.r,
      padding: padding?.r,
      constraints: constraints?.r,
      decoration: ShapeDecoration(
        shadows: showShadows
            ? [
                BoxShadow(
                  color: shadowColor ?? Colors.grey.withOpacity(0.3),
                  blurRadius: blurRadius?.r ?? 2.r,
                  spreadRadius: spreadRadius?.r ?? 1.r,
                  offset: shadowOffset ?? Offset(0, 2.r),
                )
              ]
            : null,
        shape: RoundedRectangleBorder(
          side: side ?? BorderSide.none,
          borderRadius: borderRadius?.r ?? BorderRadius.circular(radius).r,
        ),
        color: color,
      ),
      alignment: alignment,
      child: child,
    );
  }
}
